<template >
  <div :class="{ POPbox: show }" @click="show = false">
    <div class="pop-up" v-show="show">
      <ul @click="btn1">
        <h5>起床打卡</h5>
        <p>凌晨3点至12点</p>
      </ul>
      <ul @click="btn2">
        <h5>睡觉打卡</h5>
        <p>20点至凌晨3点</p>
      </ul>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "Clock",
  data() {
    return {
      show: false,
      PopUpShow: true,
      time: "",
    };
  },
  mounted() {
    this.$bus.$on("Clockshow", (show, time) => {
      this.time = time;
      this.show = show;
    });
  },
  methods: {
    btn1() {
      if (this.time > 2 && this.time < 13) {
        this.$bus.$emit("PopUpShow", this.PopUpShow);
        axios
          .post("http://123.56.24.27:8085//api/clock/early", {})
          .then((r) => {
            console.log(r);
          });
      } else {
        alert("时间未到");
      }
    },
    btn2() {
      if (this.time > 19 && this.time <= 24) {
        this.$bus.$emit("PopUpShow", this.PopUpShow);
      } else {
        alert("时间未到");
      }
    },
  },
};
</script>

<style>
.POPbox {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  position: absolute;
  top: 0;
  left: 0;
}
.pop-up {
  width: 688px;
  height: 494px;
  background: #ffffff;
  border-radius: 20px;
  position: fixed;
  bottom: 58px;
  left: 47px;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.close {
  border: 1px solid black;
  text-align: center;
  line-height: 30px;
  border-radius: 50%;
  position: absolute;
  top: 15px;
  left: 15px;
}
.pop-up ul {
  width: 260px;
  height: 360px;
  border-radius: 10px;
  background-size: 260px;
}
.pop-up ul:nth-child(1) {
  background-image: url(../../img/practice/上午打卡.jpg);
}
.pop-up ul:nth-child(2) {
  background-image: url(../../img/practice/晚上打卡.jpg);
}
.pop-up ul h5 {
  font-size: 36px;
  font-family: PingFang SC;
  font-weight: 500;
  color: #ffffff;
}
.pop-up ul p {
  font-size: 24px;
  font-family: PingFang SC;
  font-weight: 400;
  color: #ffffff;
}
</style>